package PhaseThirdModuleOne;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class Task01Driver {

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {

        //1.获取配置信息
        Configuration conf = new Configuration();
        //2.获取job对象实例
        Job job = Job.getInstance(conf);
        //3.指定本程序jar包所在本地路径
        job.setJarByClass(Task01Driver.class);
        //4.指定本业务job要是用的Mapper业务类
        job.setMapperClass(Task01Mapper.class);
        //5.指定本业务job要是用的Reducer业务类
        job.setReducerClass(Task01Reducer.class);
        //6.指定Mapper输出数据的kv类型
        job.setMapOutputKeyClass(LongWritable.class);
        job.setMapOutputValueClass(LongWritable.class);
        //7.指定最终输出数据的kv类型
        job.setOutputKeyClass(LongWritable.class);
        job.setOutputValueClass(LongWritable.class);
        //8.指定job的输入输出路径
        FileInputFormat.setInputPaths(job, new Path("E:\\input"));
        FileOutputFormat.setOutputPath(job, new Path("E:\\output"));
        //9.提交任务
        boolean flag = job.waitForCompletion(true);
        System.exit(flag ? 0 : 1);
    }
}
